{% extends "base.html" %}

{% block title %}登录 - 外卖订餐系统{% endblock %}

{% block content %}
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card shadow-lg border-0 rounded-lg">
                <div class="card-header bg-primary text-white text-center">
                    <h4 class="mb-0">用户登录</h4>
                </div>
                <div class="card-body p-4">
                    {% if form.errors %}
                    <div class="alert alert-danger">
                        用户名或密码错误，请重试。
                    </div>
                    {% endif %}

                    <form method="post">
                        {% csrf_token %}
                        <div class="form-floating mb-3">
                            <div class="input-group">
                                <span class="input-group-text"><i class="fas fa-user"></i></span>
                                {{ form.username }}
                            </div>
                            <label for="id_username">用户名</label>
                        </div>
                        <div class="form-floating mb-3">
                            <div class="input-group">
                                <span class="input-group-text"><i class="fas fa-lock"></i></span>
                                {{ form.password }}
                            </div>
                            <label for="id_password">密码</label>
                        </div>
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-danger btn-lg btn-block">登录</button>
                        </div>
                    </form>

                    <div class="mt-3 text-center">
                        <p>还没有账号？ <a href="{% url 'users:register' %}" class="text-primary">立即注册</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    body {
        background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    }
    .btn-danger {
        transition: background-color 0.3s ease;
    }
    .btn-danger:hover {
        background-color: #e3342f;
    }
</style>
{% endblock %}
